<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #chart {
      width: 600px;
      height: 400px;
    }
  </style>
  <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.0.0/echarts.min.js"></script>
</head>

<body>
  <div id="chart"></div>
  <script>
    const chartDOM = document.getElementById("chart")
    const chart = echarts.init(chartDOM, 'dark')
    chart.setOption({
      title: {
        text: 'dataset',
        subtext: '数据可视化'
      },
      xAxis: {
        data: ['一季度', '二季度', '三季度', '四季度']
      },
      dataset: {
        source: [
          ['一季度', 100, 79, '分类1', 50],
          ['二季度', 120, 81, '分类2', 55],
          ['三季度', 90, 72, '分类3', 65],
          ['四季度', 150, 101, '分类4', 75],
        ]
      },
      yAxis: {},
      legend: {
        // !图例一定要和系列的 name 属性进行绑定
        data: [{
          name: '分类',
          icon: 'circle',
          textStyle: {
            color: 'red'
          }
        }, '折线图', '柱状图'],
        left: 150
      },
      // #mark
      grid: {
        top: 100,
        left: '10%',
        right: 10,
        bottom: 100
      },
      toolbox: {
        feature: {
          dataZoom: {
            yAxisIndex: false // 不选取任何坐标轴，缩放的时候忽略坐标轴
          },
          restore: {},
          saveAsImage: {}
        }
      },
      dataZoom: [
        {
          show: true,
          start: 0,
          end: 100
        }
      ],
      series: [
        {
          name: '分类',
          type: 'pie', // 饼图
          encode: { itemName: 3, value: 4 },
          center: ['50%', 60],
          radius: 35,
        },
        {
          name: '折线图',
          type: 'line', // 折线图
          encode: { x: 0, y: 1 }
        },
        {
          name: '柱状图',
          type: 'bar', // 柱状图
          encode: { x: 0, y: 2 }
        }
      ]
    })
  </script>
</body>

</html>